package edu.bbu.bibliospring.backend.model;

import javax.persistence.*;

/**
 * Created by anna on 6/4/14.
 */

@Entity
@Table(name = "book")
//@IdClass(BaseEntity.class)
public class Book extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST)
    @JoinColumn(name="author", referencedColumnName = "id")
    protected Author author;
    @Column(name = "title")
    protected String title;
    @Column(name = "yearOfPublishing")
    protected Long yearOfPublishing;
    @Column(name = "editor")
    protected String editor;

    /**
     * reserved:
     *  - 0 if the book is not reserved;
     *  - reservationId if the book is reserved
     */
    protected Long reserved;

    /**
     * borrowed:
     *  - 0 if the book is not borrowed;
     *  - borrowingId if the book is borrowed
     */
    protected Long borrowed;

    public Book() {}

    public Book(final String title, final Long yearOfPublishing, final String editor) {
        this.title = title;
        this.yearOfPublishing = yearOfPublishing;
        this.editor = editor;
        this.reserved = 0l;
        this.borrowed = 0l;
    }

    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public Long getYearOfPublishing() {
        return yearOfPublishing;
    }

    public void setYearOfPublishing(Long yearOfPublishing) {
        this.yearOfPublishing = yearOfPublishing;
    }

    public String getEditor() {
        return editor;
    }

    public void setEditor(String editor) {
        this.editor = editor;
    }

    public Long getReserved() {
        return reserved;
    }

    public void setReserved(Long reserved) {
        this.reserved = reserved;
    }

    public Long getBorrowed() {
        return borrowed;
    }

    public void setBorrowed(Long borrowed) {
        this.borrowed = borrowed;
    }
}


